package top.songxs.gmall.item.rpc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.item.biz.SkuDetailRpcService;
import top.songxs.gmall.product.vo.SkuDetailVo;

import java.util.List;


@RestController
@RequestMapping("api/inner/item")
public class SkuDetailRpcController {

    @Autowired
    private SkuDetailRpcService skuDetailRpcService;

    @GetMapping("/detail/{skuId}")
    public Result<SkuDetailVo> getSkuDetailList(@PathVariable("skuId") Long skuId) {
        SkuDetailVo skuDetailVo = skuDetailRpcService.getSkuDetailList(skuId);

        return Result.ok(skuDetailVo);
    }

    @PutMapping("updateHotScore")
    public Result updateHotScore(@RequestParam("goodsId") Long goodsId , @RequestParam("hotScore")Integer hotScore) {
        this.skuDetailRpcService.updateHotScore(goodsId);
        return Result.ok();
    };

    public Result<List<Long>> getAllSkuId() {
        List<Long> list = skuDetailRpcService.getAllSkuId();
        return Result.ok(list);
    }

}
